﻿<UserControl x:Class="ContestMeter.Teacher.UI.BatchCheckerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:olymp="urn:rnd-olympics/2010"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>

        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Label Margin="5">Папка с решениями:</Label>
            <TextBox Grid.Row="1" Margin="5" Text="{Binding Folder}"/>
            <Button Grid.Column="1" Command="{Binding BrowseCommand}" HorizontalAlignment="Right" Margin="5" Width="90" Height="25">Обзор</Button>
            <Button Grid.Column="1" Grid.Row="1" Command="{Binding RunCommand}" HorizontalAlignment="Right" Margin="5" Width="90" Height="25">Запуск</Button>
            <Button Grid.Column="1" Grid.Row="2" Command="{Binding SaveCommand}" HorizontalAlignment="Right" Margin="5" Width="90" Height="25">Сохранить</Button>
        </Grid>
        <DockPanel Grid.Row="1">
            <DockPanel.Resources>
                <GridViewColumnCollection x:Key="TopColumns">
                    <GridViewColumn Header="Участник" DisplayMemberBinding="{Binding FullName}"/>
                    <GridViewColumn Header="Папка" DisplayMemberBinding="{Binding Folder}"/>
                    <GridViewColumn Header="Баллы" DisplayMemberBinding="{Binding Score}"/>
                    <GridViewColumn Header="">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <ProgressBar Width="100" Height="20" IsIndeterminate="True"
                                                 Visibility="{Binding IsPending, Converter={x:Static olymp:Converters.Visibility}}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridViewColumnCollection>
                <GridViewColumnCollection x:Key="DetailsColumns">
                    <GridViewColumn Header="Задача" DisplayMemberBinding="{Binding Name}"/>
                    <GridViewColumn Header="Пройдено тестов" DisplayMemberBinding="{Binding Score}" Width="50"/>
                    <GridViewColumn Header="Неверных ответов" DisplayMemberBinding="{Binding FailedChecks}" Width="50"/>
                    <GridViewColumn Header="Сбоев программы" DisplayMemberBinding="{Binding FailedRuns}" Width="50"/>
                </GridViewColumnCollection>
            </DockPanel.Resources>
            <GridViewHeaderRowPresenter Margin="45 0 0 0" DockPanel.Dock="Top" Columns="{StaticResource TopColumns}"/>

            <TreeView ItemsSource="{Binding Records}">

                <TreeView.ItemTemplate>
                    <DataTemplate>
                        <TreeViewItem ItemsSource="{Binding Solutions}">
                            <TreeViewItem.Header>
                                <GridViewRowPresenter Columns="{StaticResource TopColumns}"/>
                            </TreeViewItem.Header>
                            <TreeViewItem.ItemTemplate>
                                <DataTemplate>
                                    <GridViewRowPresenter Columns="{StaticResource DetailsColumns}"/>
                                </DataTemplate>
                            </TreeViewItem.ItemTemplate>
                        </TreeViewItem>
                    </DataTemplate>
                </TreeView.ItemTemplate>
            </TreeView>
        </DockPanel>
    </Grid>
</UserControl>
